package com.itheima.mycollection;

import java.util.ArrayList;
import java.util.Iterator;

public class Demo3 {
    public static void main(String[] args) {
        ArrayList<Student> list=new ArrayList<>();
        list.add(new Student("张三",23));
        list.add(new Student("李四",22));
        list.add(new Student("王五",21));
        //增强for
        for (Student student : list) {
            System.out.println(student);
        }
        System.out.println("...........");
        //迭代
        Iterator<Student> it=list.iterator();
        while (it.hasNext()){
            Student stu=it.next();
            System.out.println(stu);
        }
        System.out.println("..................");
        //普通for循环
        for (int i = 0; i < list.size(); i++) {
           Student stu= list.get(i);
            System.out.println(stu);

        }


    }


}
